Skip to content

fix: Improve compatibility with Alpine Linux - #68

Merged
fractaledmind merged 3 commits into
fractaledmind:mainfrom
jherdman:improve-compatibility
Oct 13, 2026
Merged

fractaledmind merged 3 commits into
fractaledmind:mainfrom
jherdman:improve-compatibility

Conversation

@jherdman

@jherdman jherdman commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

Alpine's ps doesn't support the -x command. SO suggests -ef is more than sufficient as a replacement.

Alpine's `ps` doesn't support the `-x` command. SO suggests `-ef` is
more than sufficient as a replacement.
@jherdman

Copy link
Copy Markdown
Contributor Author

Is there anything I can do to help this along?

@fractaledmind

Copy link
Copy Markdown
Owner

Is there anything I can do to help this along?

Hey, I'm sorry for the delay. My wife and I just had a baby a few weeks ago, and I've taken the last few months off to focus on helping her and now our baby. But, this looks good. I'll merge and release when I get back to my laptop in November

@jherdman

Copy link
Copy Markdown
Contributor Author

Congrats!

@alxvernier

Copy link
Copy Markdown
Contributor

#73 uses the new Litestream IPC endpoints from v0.5.9, so no more specific linux specific commands are needed.

@fractaledmind fractaledmind left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, and sorry for the long wait. I can't merge it as it stands: with ps -ef, the first column on macOS and glibc Linux is the UID, not the PID, and process_info takes the first field as the pid (pid, * = line.split(" ")). On those systems the dashboard would report the user id and then run ps -o "state,lstart" <uid>. The test still passes because its stubbed ps output is in the old -ax layout.

ps -eo pid,args puts the PID first on macOS, GNU and (I believe) BusyBox, so it should cover Alpine without breaking the others. If you can confirm it on Alpine, and change the test stub to match the new command's output layout, I'll merge it.

🤖 Generated with Claude Code

fractaledmind and others added 2 commits October 13, 2026 14:03
ps differs too much across images to parse: BusyBox (Alpine) rejects
-x and has no lstart, Debian slim ships no ps at all, and with -ef the
first column is the UID on macOS and glibc. On Linux, read argv, state
and start time from /proc. On macOS, one ps call with the command name
in its own column.

Match on the program (argv[0] named litestream, argv[1] replicate)
rather than the text "litestream replicate" anywhere in the command
line, which also matched shells and editors that mentioned it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@fractaledmind

Copy link
Copy Markdown
Owner

I pushed a change to this branch, building on your fix. Testing in containers showed that ps can't be made to work everywhere:

  • Alpine (BusyBox): -ef gets the pid right, but the next call, ps -o "state,lstart" <pid>, fails (bad -o argument 'state'), and the code then raised a NoMethodError and returned a 500.
  • Debian slim (ruby:*-slim, which Rails' generated Dockerfile uses): there's no ps at all, so the process was never shown.
  • macOS and full Debian: -ef puts the UID in the first column.

The change:

  • Linux now reads the process's arguments, state and start time from /proc, so it no longer depends on ps.
  • macOS uses one ps -axo pid=,stat=,lstart=,comm= call.
  • Both match on the program itself (argv[0] named litestream, argv[1] replicate). Previously any command line containing the text matched, including a shell or a tail that mentioned it.

I checked it with a real process (in a path containing a space) and a decoy shell on ruby:3.3-alpine, ruby:3.3-slim, ruby:3.3 and ruby:3.4-slim, and on macOS. The README note about installing ps is gone, since Linux no longer needs it.

🤖 Generated with Claude Code

@fractaledmind
fractaledmind merged commit 317ad0f into fractaledmind:main Oct 13, 2026
10 of 11 checks passed
@jherdman

Copy link
Copy Markdown
Contributor Author

Many thanks for following up! I hope all is well with your family.

@jherdman
jherdman deleted the improve-compatibility branch October 13, 2026 15:21
@fractaledmind

Copy link
Copy Markdown
Owner

Yes, my daughter just recently had her 1 year birthday! It is freaking crazy how quickly time flies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants